package cn.wegoteam.shop.service;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.wegoteam.shop.inter.BaseDaoInter;
import cn.wegoteam.shop.inter.CartServiceInter;
import cn.wegoteam.shop.po.Cart;
import cn.wegoteam.shop.util.Const;
import cn.wegoteam.shop.util.GetReqRes;
import cn.wegoteam.shop.util.MyString;

@Service
public class CartService extends BaseService<Cart> implements
		CartServiceInter {
	
	public void deleteFromCart(String ids,Map<String,Object> session){
		Map<String,Cart> cs= Cart.getCarts(false);
		for(String id:ids.split(",")){
			if(cs.containsKey(id)){
				cs.remove(id);
			}
		}
		GetReqRes.addCookie(Const.SESS_GOODS, Cart.getCookieString(cs));
		session.put(Const.SESS_GOODS_NUM, cs.size());
	}
	@Resource(name="cartDao")
	public void setBaseDao(BaseDaoInter<Cart> baseDao) {
		super.setBaseDao(baseDao);
	}
}
